package com.spotmanger.project.modular.spottable.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spotmanger.project.common.core.utils.DataResult;
import com.spotmanger.project.modular.spottable.entity.SpottablePolicyclosedEntity;
import com.spotmanger.project.modular.spottable.entity.SpottablePolicyclosedEntity;
import com.spotmanger.project.modular.spottable.service.SpottablePolicyclosedService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;



/**
 * 政策性关闭矿山的信息表，所有政策性关闭的矿山图斑录入均需要填写该表。
 *
 * @author leihao
 * @email 1321451088@qq.com
 * @date 2021-09-20 10:53:23
 */
@Controller
@RequestMapping("/")
public class SpottablePolicyclosedController {
    @Resource
    private SpottablePolicyclosedService SpottablePolicyclosedService;


    /**
     * 跳转到页面
     */
    @GetMapping("/index/policyclosedmine")
    public String spottablePolicyclosed() {
        return "spottable/spottablepolicyclosed/list";
    }


    @ApiOperation(value = "新增")
    @PostMapping("policyclosedmine/add")
    @RequiresPermissions("policyclosedmine:add")
    @ResponseBody
    public DataResult add(@RequestBody SpottablePolicyclosedEntity spottablePolicyclosed){
        SpottablePolicyclosedService.save(spottablePolicyclosed);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("policyclosedmine/delete")
    @RequiresPermissions("policyclosedmine:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> TBBHs){
        SpottablePolicyclosedService.removeByIds(TBBHs);
        return DataResult.success();
    }
    @ApiOperation(value = "更新")
    @PutMapping("policyclosedmine/update")
    @RequiresPermissions("policyclosedmine:update")
    @ResponseBody
    public DataResult update(@RequestBody SpottablePolicyclosedEntity spottablePolicyclosed){
        SpottablePolicyclosedService.updateById(spottablePolicyclosed);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("policyclosedmine/listByPage")
    @RequiresPermissions("policyclosedmine:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody SpottablePolicyclosedEntity spottablePolicyclosed){
        Page page = new Page(spottablePolicyclosed.getPage(), spottablePolicyclosed.getLimit());
        LambdaQueryWrapper<SpottablePolicyclosedEntity> queryWrapper = SpottablePolicyclosedService.searchByTBBH(spottablePolicyclosed);
        IPage<SpottablePolicyclosedEntity> iPage = SpottablePolicyclosedService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
